package wickethub.web.page;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import wickethub.domain.Snippet;

public class EditSnippetPanel extends Panel {
	
	public EditSnippetPanel(String id, IModel<Snippet> model) {
		super(id);
		
		setDefaultModel(model.getObject() instanceof Snippet ? model : new Model<Snippet>(new Snippet()));
		
    	final Form<Snippet> form = new Form<Snippet>("form", new CompoundPropertyModel<Snippet>(getDefaultModel()));
		
    	form.add(new TextArea<String>("description"));
		form.add(new TextArea<String>("code").setRequired(true));
		
		add(form);
        
    }
    
}